package datamining.associations.apriori;

import java.io.File;
import weka.associations.Apriori;
import weka.core.Instances;
import weka.core.converters.ConverterUtils.DataSource;

public class AprioriOutput {

  /**
   * Expects a dataset as first parameter. The last attribute is used
   * as class attribute.
   *
   * @param args	the command-line parameters
   * @throws Exception	if something goes wrong
   */
  public static void main(String[] args) throws Exception {
    // load data
    Instances data = DataSource.read(args[0]);
    data.setClassIndex(data.numAttributes() - 1);

    // build associator
    Apriori apriori = new Apriori();
    apriori.setClassIndex(data.classIndex());
    apriori.buildAssociations(data);

    // output associator
    System.out.println(apriori);
  }
  
  public static void Run(File dataSet) throws Exception{
		Instances data = DataSource.read(dataSet.getAbsolutePath());
		data.setClassIndex(data.numAttributes() - 1);

		// build associator
		Apriori apriori = new Apriori();
		apriori.setClassIndex(data.classIndex());
		apriori.setNumRules(100);
		apriori.buildAssociations(data);

		// output associator
		System.out.println(apriori);
  }
}